/**
 * 显示单选商品弹框
 * @param obj
 */
function showOneGoods(obj,callback) {
    In('layer',function () {
        var url = $(obj).data('url');
        var siteId = $(obj).data('siteid');
        var field = $(obj).data('field');
        $.get(url, {site_id:siteId}, function(html){
            layer.open({
                type: 1,
                title:'选择商品',
                area: ['760px', '680px'], //宽高
                content: html,
                end: function(index, layero){ //关闭清除本地缓存
                    var sku_id=localStorage.getItem('sku_id');
                    var sku_info=JSON.parse(localStorage.getItem('sku_info'));
                    var sku={"sku_id":sku_id,'sku_info':sku_info};
                    localStorage.removeItem("sku_id");
                    localStorage.removeItem("sku_info");
                    callback(field,sku);
                }
            });
        });
    })
}
/**
 * 显示多选商品弹框
 * @param obj
 */
function showMoreGoods(obj,callback) {
    In('layer',function () {
        var url = $(obj).data('url');
        var siteId = $(obj).data('siteid');
        var field = $(obj).data('field');
        $.get(url, {site_id:siteId}, function(html){
            layer.open({
                type: 1,
                title:'选择商品',
                area: ['760px', '680px'], //宽高
                content: html,
                btn: ['确认选择','暂存选取'],
                yes: function(index, layero){  //确认选择后清除本地缓存
                    var sku_ids=localStorage.getItem('sku_ids');
                    var sku_list=JSON.parse(localStorage.getItem('sku_list'));
                    var sku={"sku_ids":sku_ids,'sku_list':sku_list};
                    localStorage.removeItem("sku_ids");
                    localStorage.removeItem("sku_list");
                    callback(field,sku);
                    layer.close(index);
                },
                btn2: function(index, layero){
                    layer.close(index);
                },
                cancel: function(index, layero){ //关闭清除本地缓存
                    localStorage.removeItem("sku_ids");
                    localStorage.removeItem("sku_list");
                    layer.close(index);
                }
            });
        });
    })
}
/*
单选例子
<div class="div_show_one_goods">
    <a class="btn btn-info" onclick="showOneGoods(this,setOneGoods);" data-field="sku_id" data-siteid="{$site_id}" data-url="{:url('plus/Goods/selectone')}">
        选择商品
    </a>
    <div class="one_goods_sku_id" style="margin-top:4px;">
        <input type="text" name="sku_id" value="" />
        <div class="row"></div>
    </div>
</div>
In('selectgoods');
function setOneGoods(field,sku){

}
 */